package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.mine.bean.RechargeInfoBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.RechargeActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;


public class RechargeActivityPresenter extends BasePresenter<RechargeActivity> {


    /**
     * 充值
     *
     * @param code 币种码
     * @param type 类型 ETH 1，BTC 2，BCH 3
     * @return
     */
    public void recharge(String code, String type) {
        httpService.recharge(code, type)
                .tag(this)
                .execute(new JsonCallBack<HttpData<RechargeInfoBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<RechargeInfoBean>> response) {
                        HttpData<RechargeInfoBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateView(httpData.getData());
                        } else {
                            ToastUtil.showShort(httpData.getMsg());
                        }
                    }
                });
    }
}
